home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / ease3.5 / part02 < prev    next >
Encoding:
Internet Message Format  |  1991-12-09  |  56.4 KB

  1. Subject:  v25i018:  Ease 3.5 - high-level sendmail.cf language, Part02/06
  2. Newsgroups: comp.sources.unix
  3. Approved: vixie@pa.dec.com
  4.  
  5. Submitted-by: Bruce G. Barnett <barnett@crdgw1.ge.com>
  6. Posting-number: Volume 25, Issue 18
  7. Archive-name: ease3.5/part02
  8.  
  9. #! /bin/sh
  10. # This is a shell archive.  Remove anything before this line, then unpack
  11. # it by saving it into a file and typing "sh file".  To overwrite existing
  12. # files, type "sh file -c".  You can also feed this as standard input via
  13. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  14. # will see the following message at the end:
  15. #        "End of archive 2 (of 6)."
  16. # Contents:  CONVERTING Makefile doc/cfc.man src/Makefile src/ease.sh
  17. #   src/errors.c src/idman.c src/lexan.patch src/symtab.c test/test.mc
  18. # Wrapped by vixie@cognition.pa.dec.com on Tue Dec 10 08:45:56 1991
  19. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  20. if test -f 'CONVERTING' -a "${1}" != "-c" ; then 
  21.   echo shar: Will not clobber existing file \"'CONVERTING'\"
  22. else
  23. echo shar: Extracting \"'CONVERTING'\" \(5098 characters\)
  24. sed "s/^X//" >'CONVERTING' <<'END_OF_FILE'
  25. X=====================================================================
  26. X    Converting a sendmail file into ease
  27. X
  28. X
  29. Step 1.  Use cfc to convert the sendmail file into ease.
  30. X    You may want to use "make convert" in the top Makefile
  31. X
  32. X    As a start, use the following arguments to cfc 
  33. X
  34. X    SunOS 4.0, /usr/lib/sendmail.subsidiary.cf
  35. X        => cfc -s -C V < /usr/lib/sendmail.subsidiary.cf>sendmail.ease
  36. X
  37. X    SunOS 4.0, /usr/lib/sendmail.main.cf
  38. X
  39. X        => cfc -s < /usr/lib/sendmail.main.cf>sendmail.ease
  40. X
  41. X
  42. X    Ultrix 3.0: 
  43. X
  44. X        => cfc -d -C SDIZFN </etc/sendmail.cf >sendmail.ease
  45. X
  46. X    IDA sendmail
  47. X
  48. X        => cfc -i
  49. X
  50. X    4.2 sendmail
  51. X
  52. X        => cfc -c
  53. X
  54. X    4.3 sendmail
  55. X
  56. X        => cdc -u
  57. X
  58. X    HP/UX
  59. X        => cfc -i -CGUS
  60. X
  61. X    A/UX
  62. X        => cfc -i -CUNI
  63. X
  64. X    CGI IRIS
  65. X        => cfc -i -C FKSVN  
  66. X
  67. X    smail
  68. X
  69. X        => cfc -C DUET
  70. X
  71. Step 2.  Convert the ease file to cf: 
  72. X
  73. X    % et <sendmail.ease >sendmail.cf
  74. X
  75. X    Look at the errors and warnings.
  76. X
  77. X    Most of these errors can be eliminated by using the right
  78. X    flags on cfc. Make sure that you specify all of the
  79. X    classes (using the -C flag ) that you need, which generate
  80. X    the matching field definitions for any_in_? fields.
  81. X    Then repeat the cf-> ease translation with the necessary
  82. X    -C XYZ flags.
  83. X
  84. X    The remaining errors are either warnings or mistakes
  85. X    in the translation. 
  86. X    Let's look at some examples:
  87. X
  88. X        line 1598: Warning: Ruleset not defined: RULESET_12
  89. X
  90. X    This says there is a line that has
  91. X        RULESET_12 = ruleset 12;
  92. X
  93. X    Comment it out if you wish.
  94. X
  95. X
  96. X    case 2)
  97. X
  98. X        line 1598: Warning: Macro not defined: Y
  99. X    or
  100. X        line 1598: Warning: Class not defined: Y
  101. X
  102. X    This is just a warning and is probably okay. There may be a rule that 
  103. X    does different actions if the macro is set or not. Example:
  104. X
  105. X    if ( one_or_more )    /* add local domain */
  106. X        next (concat ("$1<@",ifset (Y, "${Y}", "${m_sitename}"))>);
  107. X
  108. X    If this bothers you, rewrite to rule to not need the Y macro:
  109. X
  110. X    if ( one_or_more )    /* add local domain */
  111. X        next ("$1<@${m_sitename}"))>);
  112. X
  113. X    Do not define them, even to define them to be nothing!
  114. X    An empty string is still defined, and may break your sendmail rules.
  115. X
  116. X    case 3)
  117. X
  118. X        line 88 near ";": Warning: Appending to previously defined class T.
  119. X    This is okay. Sendmail allows you to define a class over several lines.
  120. X    combine them into one line if you wish.
  121. X
  122. X    case 4)
  123. X
  124. X    line 1485: Warning: Mailer not defined: ERROR
  125. X
  126. X    Ease treats upper and lower case letters as different.
  127. X    Sendmail does not. Change the case to be consistent
  128. X
  129. X    case 5)
  130. X
  131. X    warning: Unknown option 'M' on line 387
  132. X    
  133. X    cfc found an unusual option. It tries to convert it into
  134. X        an asm("...') string.
  135. X
  136. X
  137. X    .....
  138. X    So look at the warnings and errors, and repeat step 1 until you 
  139. X    feel comfortable with the change.
  140. X
  141. X    If you can't get cfc/ease to accept the new syntax, use the
  142. X    asm(" ") construct to work around it and report the bugs.
  143. X
  144. Step 3. Verify the ease output matches the original sendmail
  145. X
  146. X    You can use  "make test_conversion" it you wish
  147. X
  148. X    At this point, you should verify that the ease output is identical to
  149. X    the original sendmail.cf file. Use the script cfdiff to
  150. X    compare the original sendmail.cf file with the ease output file.
  151. X
  152. X    That is, if your original sendmail file is /etc/sendmail.cf,
  153. X    and the new one is ./sendmail.cf, do a
  154. X
  155. X     set path = ( $cwd/bin $path );rehash;cfdiff /etc/sendmail.cf ./sendmail.cf
  156. X
  157. X    You may see some differences. Examples:
  158. X
  159. X    < Odbackground
  160. X    ---
  161. X    > Odb
  162. X
  163. X    Okay: ease outputs the full name instead of the abbreviation
  164. X
  165. X    < Muucp,    P=/usr/bin/uux, F=sDFhuU, S=13, R=23, M=100000,
  166. X    <     A=uux - $h!rmail ($u)
  167. X    ---
  168. X    > Muucp, P=/usr/bin/uux, F=sDFhuU, S=13, R=23, M=100000, A=uux - $h!rmail ($u)
  169. X
  170. X    Okay: this is on two lines instead of one.
  171. X
  172. X    < CTuucp UUCP arpa ARPA bitnet BITNET csnet CSNET mailnet MAILNET decnet DECNET rscs RSCS
  173. X    ---
  174. X    > CTuucp UUCP arpa ARPA bitnet BITNET csnet CSNET mailnet
  175. X    > CTMAILNET decnet DECNET rscs RSCS
  176. X    
  177. X    OKAY: this is just a different number of lines.
  178. X
  179. X
  180. X    Differences in the spaces in the rules)
  181. X    The syntax of sendmail specifies that there are tabs between the 
  182. X    left hand side and the right hand side, and a tab between the right 
  183. X    hand side and the comments.
  184. X
  185. X    Any spaces in the middle of the rules are cosmetic. Ignore differences.
  186. X
  187. X    If there is any other difference, 
  188. X    please send me a bug report, and see if you can make changes to your
  189. X    ease input file to match the original file. You may need the asm("")
  190. X    command.
  191. X
  192. X    If your diff program has the -w option, you can ignore spaces in the
  193. X    cf files. Occasionally ease inserts some extra spaces. Or the
  194. X    original sendmail file has extra spaces. (e.g. SunOS).
  195. X    See the script cfdiff.
  196. X
  197. Step 4. Once you have the ease file in good form, put it under sccs
  198. X    control, and put the version number (%W% in the V macro
  199. X    definition, so the "Received-by" header line reflects the revision.)
  200. X
  201. You are now ready to debug your sendmail file.
  202. See the file TESTING
  203. X============================================================================
  204. X
  205. If you find these programs useful, or if you have suggestions or changes,
  206. please drop me a line.
  207. X
  208. X    Bruce Barnett
  209. X    General Electric
  210. X    Corporate Research and Development
  211. X    P. O. Box 8, 1 River Road
  212. X    Schenectady, NY 12302
  213. X
  214. X    barnett@crdgw1.ge.com
  215. END_OF_FILE
  216. if test 5098 -ne `wc -c <'CONVERTING'`; then
  217.     echo shar: \"'CONVERTING'\" unpacked with wrong size!
  218. fi
  219. # end of 'CONVERTING'
  220. fi
  221. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  222.   echo shar: Will not clobber existing file \"'Makefile'\"
  223. else
  224. echo shar: Extracting \"'Makefile'\" \(3046 characters\)
  225. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  226. X#    $Header: /home/kreskin/u0/barnett/Src/Ease/ease/RCS/Makefile,v 3.4 1991/10/15 17:37:27 barnett Exp $
  227. X#
  228. X#    $Log: Makefile,v $
  229. X# Revision 3.4  1991/10/15  17:37:27  barnett
  230. X# Changed 'make shar'
  231. X#
  232. X# Revision 3.3  1991/09/09  16:41:11  barnett
  233. X# added '-' to /bin/rm in "make all"
  234. X#
  235. X# Revision 3.2  1991/05/16  10:51:13  barnett
  236. X# Fixed a few typos and added the MAKE variable
  237. X#
  238. X# Revision 1.2  1991/02/25  22:07:29  barnett
  239. X# Added RCS header, amd specified value for MAKE variable
  240. X#
  241. X# Revision 1.1  1991/02/25  14:37:28  barnett
  242. X# Initial revision - release to net
  243. X#
  244. X#
  245. X# where do you want to place the binaries and scripts?
  246. X# the programs are: et cfc cfdiff cfstrip
  247. BINDIR=`pwd`/bin
  248. X
  249. X#where is your original sendmail file?
  250. X#ORIGINAL=/etc/sendmail.cf
  251. ORIGINAL=/usr/lib/sendmail.cf
  252. X#ORIGINAL=/usr/lib/sendmail.main.cf
  253. X#ORIGINAL=/usr/lib/sendmail.subsidiary.cf
  254. X
  255. X# What arguments to cfc do you want for cfc (see the file CONVERTING)
  256. X# IDA
  257. X#CONVERT_FLAGS=-i
  258. X#SunOS Subsidiary
  259. CONVERT_FLAGS=-s -CV
  260. X
  261. X#what extenstion do you want for the manual pages?
  262. X#EXT=1
  263. X#EXT=l
  264. XEXT=n
  265. SHELL=/bin/sh
  266. MAKE=make
  267. X
  268. all:
  269. X    cd cfc; ${MAKE} ${FLAGS}  $@
  270. X    cd src; ${MAKE} ${FLAGS}  $@
  271. X    cd utils; ${MAKE} ${FLAGS}  $@
  272. X    touch all
  273. X    
  274. install:
  275. X    test -d ${BINDIR} || mkdir ${BINDIR}
  276. X#    cd cf; make $(MFLAGS) $@
  277. X    BD=${BINDIR};cd cfc; ${MAKE} ${MFLAGS} BINDIR=$$BD $@
  278. X    BD=${BINDIR};cd src; ${MAKE} ${MFLAGS} BINDIR=$$BD $@
  279. X    BD=${BINDIR};cd utils; ${MAKE} ${MFLAGS} BINDIR=$$BD $@
  280. X    cd doc; ${MAKE} ${MFLAGS} EXT=${EXT} $@
  281. X
  282. X
  283. X
  284. convert:    ${ORIGINAL} all 
  285. X        ${BINDIR}/cfc ${CONVERT_FLAGS} < ${ORIGINAL} >sendmail.ease
  286. X
  287. test_conversion:    ${ORIGINAL} sendmail.cf
  288. X    PATH=${BINDIR}:$$PATH;export PATH;cfdiff ${ORIGINAL} sendmail.cf
  289. X
  290. clean:
  291. X#    cd cf; make $(MFLAGS) $@
  292. X    cd src; ${MAKE} ${MFLAGS} $@
  293. X    cd cfc; ${MAKE} ${MFLAGS} $@
  294. X    cd utils; ${MAKE} ${MFLAGS} $@
  295. X    -/bin/rm all
  296. X
  297. X
  298. debug:    all sendmail.ease
  299. X    BD=${BINDIR};cd debug; ${MAKE} ${MFLAGS} BINDIR=$$BD $@
  300. sendmail.ease:
  301. X    @ echo where is the sendmail.ease file you want to debug?    
  302. X
  303. sendmail.cf: all sendmail.ease
  304. X    ${BINDIR}/et <sendmail.ease >sendmail.cf
  305. X
  306. hostname.ease: SCCS/s.hostname.ease
  307. X    sccs get hostname.ease
  308. X
  309. hostname.cf:    hostname.ease
  310. X    et -C <hostname.ease >hostname.cf
  311. X
  312. install_hostname: hostname.cf
  313. X    @sccs check
  314. X    /bin/mv ${ORIGINAL} ${ORIGINAL}.old
  315. X    /bin/cp hostname.cf ${ORIGINAL}
  316. X    build-new-aliases
  317. X
  318. mail: Part01 Part02 Part03 Part04 Part05 Part06
  319. X    @ WHO=${WHO} && \
  320. X    [ $${WHO:-missing} = missing ] && \
  321. X    echo USAGE:  make mail WHO=address || \
  322. X    (( mail -s "Ease 3.0: Part 1 of 6" $${WHO} <Part01) ;\
  323. X     ( mail -s "Ease 3.0: Part 2 of 6" $${WHO} <Part02) ;\
  324. X     ( mail -s "Ease 3.0: Part 3 of 6" $${WHO} <Part03) ;\
  325. X     ( mail -s "Ease 3.0: Part 4 of 6" $${WHO} <Part04) ;\
  326. X     ( mail -s "Ease 3.0: Part 5 of 6" $${WHO} <Part05) ;\
  327. X     ( mail -s "Ease 3.0: Part 6 of 6" $${WHO} <Part06; ))
  328. X
  329. depend lint print:
  330. X    -for dir in *; do [ -f $$dir/[Mm]akefile ] && (cd $$dir; make $(MFLAGS) $@); done
  331. X
  332. shar:
  333. X    dirname=`basename $$PWD`; cd ..; shar `find $$dirname -name RCS -prune -o -name GE -prune -o -type f -print|egrep -v '~|#' ` >/tmp/ease.shar
  334. X
  335. END_OF_FILE
  336. if test 3046 -ne `wc -c <'Makefile'`; then
  337.     echo shar: \"'Makefile'\" unpacked with wrong size!
  338. fi
  339. # end of 'Makefile'
  340. fi
  341. if test -f 'doc/cfc.man' -a "${1}" != "-c" ; then 
  342.   echo shar: Will not clobber existing file \"'doc/cfc.man'\"
  343. else
  344. echo shar: Extracting \"'doc/cfc.man'\" \(5783 characters\)
  345. sed "s/^X//" >'doc/cfc.man' <<'END_OF_FILE'
  346. X...
  347. X... $Header: /tmp_mnt/home/kreskin/u0/barnett/Src/Ease/ease/doc/RCS/cfc.man,v 3.3 1991/09/09 16:36:05 barnett Exp $
  348. X... 
  349. X... $Log: cfc.man,v $
  350. X... Revision 3.3  1991/09/09  16:36:05  barnett
  351. X... minor bug fixes
  352. X...
  353. X... Revision 1.2  1990/04/04  15:42:51  jeff
  354. X... Reformatted somewhat for readability.  Added some bugs
  355. X... described by Bruce Barnett.
  356. X...
  357. X... Version 1.1  90/04/04  14:57:38  jeff
  358. X... Initial version
  359. X... 
  360. X... Revision 2.0  88/06/15  15:17:36  arnold
  361. X... Baseline release for net posting. ADR.
  362. X... 
  363. X... Revision 1.3  88/01/21  16:23:21  arnold
  364. X... Some typo fixes.
  365. X... 
  366. X... Revision 1.2  87/04/08  10:21:47  arnold
  367. X... Small bug fixes, compatibility option added, also warnings for
  368. X... unrecognized flags and options. ADR.
  369. X... 
  370. X... Revision 1.1  87/02/16  15:25:32  arnold
  371. X... Initial revision
  372. X... 
  373. X...
  374. X.TH CFC local
  375. X.SH NAME
  376. cfc \- Sendmail cf file compiler
  377. X.SH SYNOPSIS
  378. X.B cfc
  379. X[
  380. X.B \-s
  381. X] [
  382. X.B \-i
  383. X] [
  384. X.B \-d
  385. X] [
  386. X.B \-c
  387. X] [
  388. X.B \-u
  389. X] [
  390. X.B \-C \fICLASSES\fP
  391. X] <
  392. X.I sendmail.cf-file
  393. X>
  394. X.I ease-source-file
  395. X.SH DESCRIPTION
  396. X.I Cfc
  397. is a filter that reads a raw
  398. X.IR sendmail (8)
  399. configuration file on its standard input, and produces almost useable
  400. X.IR ease (1)
  401. source on its standard output.
  402. X.P
  403. It is designed as a conversion tool, to translate an existing
  404. X.B sendmail.cf
  405. file into
  406. X.I ease
  407. with the idea that all future work will be done in
  408. X.IR ease .
  409. X.P
  410. X.I Cfc
  411. passes all comments through to the output, and converts all predefined
  412. X.I sendmail
  413. macros, options, option values, and mailer flags into the names used by
  414. X.IR ease .
  415. X.P
  416. It is suggested you use
  417. X.I cfc
  418. to convert a 
  419. X.I sendmail.cf
  420. file into 
  421. X.I ease
  422. format, and then convert the
  423. X.I ease
  424. file back into
  425. X.I sendmail
  426. format.
  427. You may have to experiment with the right options and the right combinations
  428. before
  429. X.I ease
  430. will generate an output file with no errors.
  431. Then use the
  432. X.I cfdiff
  433. script to compare the original
  434. X.I sendmail.cf
  435. file to the output of
  436. X.IR ease .
  437. You should see some differences in formatting, as some 
  438. X.I sendmail
  439. lines can be on one or two lines, and some options have more than one form.
  440. Once it is determined that these are the only difference, you should feel
  441. very comfortable using 
  442. X.I ease
  443. as a high level langauge for 
  444. X.I sendmail 
  445. files.
  446. If you are unable to make the two files identical, you may need to modify the 
  447. X.I ease
  448. input file so the output is correct.
  449. If necessary, you can use the
  450. X.IR asm ()
  451. function in
  452. X.I ease
  453. to pass the characters, unchanged, to the output.
  454. X.P
  455. X.I Cfc
  456. isn't perfect. 
  457. You may wish to modify the 
  458. X.I ease
  459. file for cosmetic reasons:
  460. X.IP
  461. X.I Cfc
  462. introduces tabs on its own, as well as often passing through tabs
  463. from the
  464. X.I sendmail
  465. input.
  466. It will also print a header for each different type of line, e.g. if the
  467. input had seven
  468. X.B O
  469. X(option) lines, there will be seven option blocks.
  470. These are usually succesive, and can therefore be merged.
  471. X.IP
  472. Move some comments.
  473. The block close on rulesets often comes after the comments that
  474. precede the next ruleset or mailer specification.
  475. X
  476. X.RE
  477. X.P
  478. In short,
  479. X.I cfc
  480. does over 99% of the tedious work of translating a
  481. X.B sendmail.cf
  482. into
  483. X.I ease
  484. format.
  485. Suprisingly, the combination of
  486. X.I cfc
  487. and
  488. X.I ease
  489. can find bugs in a current
  490. X.B sendmail.cf
  491. file!
  492. X.P
  493. X.I Cfc
  494. takes five options.
  495. X.RS
  496. X.TP
  497. X.B \-c
  498. Indicates that
  499. X.I cfc
  500. should run in 4.2BSD compatibility mode.
  501. In this case, options and mailer flags which are new in the 4.3BSD
  502. version of
  503. X.I sendmail
  504. will not be recognized.
  505. X.TP
  506. X.B \-u
  507. X.I Cfc
  508. will warn about the use of any undocumented options or mailer flags in
  509. the 4.3BSD
  510. X.IR sendmail .
  511. The correct
  512. X.I ease
  513. output will still be produced.
  514. X.TP
  515. X.B \-s
  516. X.I Cfc
  517. will assume the input file is for Sun's sendmail.
  518. It will produce a ruleset definition for rule number 30, which Sun uses
  519. in their standard configuration file, and older implementations
  520. complain about. It also adds some declarations that match Sun's
  521. additions to sendmail, so errors won't occur.
  522. X.TP
  523. X.B \-d
  524. X.I Cfc
  525. will cause some definitions to be added that will convert the Ultrix
  526. X.i sendmail.cf
  527. file with fewer errors.
  528. X.TP
  529. X.B \-i
  530. X.I Cfc
  531. will add some declarations that the IDA version of 
  532. X.I sendmail
  533. likes to see.
  534. X.TP
  535. X.B \-C
  536. X<LETTER><LETTER>...
  537. X.I Cfc
  538. will add an additional header of the form
  539. X.I any_in_<LETTER>
  540. and
  541. X.I any_not_in_<LETTER>
  542. where
  543. X.I <LETTER>
  544. is a single character that specifes a class used in the sendmail file,
  545. but not defined.
  546. This prevents 
  547. X.I ease
  548. from complaining about undefined classes.
  549. X.RE
  550. X.P
  551. With the right compination of options and class definitions, it is
  552. easy to convert a 
  553. X.I sendmail
  554. file into 
  555. X.I ease ,
  556. edit the file, and run 
  557. X.I ease
  558. on the file, and install the output.
  559. X.\" .SH FILES
  560. X.SH SEE ALSO
  561. X.I "Sendmail Installation and Operation Guide"
  562. by Eric Allman
  563. X(SMM:7 in the 4.3 BSD UNIX System Manager's Manual),
  564. X.I "Ease: A Configuration Language for Sendmail"
  565. by James S. Schoner, amended by Jeff P. Stearns, Arnold D. Robbins, and Bruce G. Barnett.
  566. X.IR sendmail (8),
  567. X.IR ease (1).
  568. X.SH DIAGNOSTICS
  569. X``\c
  570. X.IR Routine :
  571. malformed input line
  572. X.IR line :
  573. fatal error''
  574. for input it doesn't understand.
  575. X.I Routine
  576. is the name of the routine in
  577. X.I cfc
  578. which choked, and
  579. X.I line
  580. is the line number in the input.
  581. X.SH BUGS
  582. Only recognizes continuation lines (lines that begin with a \s-1TAB\s+1)
  583. for header (H) and mailer (M) definitions.
  584. X.P
  585. Should read from files on the command line, instead of being a pure filter.
  586. X.P
  587. Should be a two pass program, and learn the classes which need
  588. defining automatically. The
  589. X.B \-C
  590. option is really a kludge.
  591. X.PP
  592. In some cases, you can use the
  593. X\fIasm(".......")\fP
  594. command to work around problems.
  595. X.SH AUTHOR
  596. X.nf
  597. Arnold Robbins
  598. XEmory University Computing Center
  599. arnold@emory.edu
  600. X
  601. Modifications by Bruce G. Barnett
  602. General Electric, Corporate Research and Development
  603. barnett@crdgw1.ge.com
  604. X
  605. X.fi
  606. END_OF_FILE
  607. if test 5783 -ne `wc -c <'doc/cfc.man'`; then
  608.     echo shar: \"'doc/cfc.man'\" unpacked with wrong size!
  609. fi
  610. # end of 'doc/cfc.man'
  611. fi
  612. if test -f 'src/Makefile' -a "${1}" != "-c" ; then 
  613.   echo shar: Will not clobber existing file \"'src/Makefile'\"
  614. else
  615. echo shar: Extracting \"'src/Makefile'\" \(4585 characters\)
  616. sed "s/^X//" >'src/Makefile' <<'END_OF_FILE'
  617. X# Makefile for Ease Translator (et).
  618. X#
  619. X#    $Header: /tmp_mnt/home/kreskin/u0/barnett/Src/Ease/ease/src/RCS/Makefile,v 3.3 1991/09/09 16:33:23 barnett Exp $
  620. X#
  621. X#    $Log: Makefile,v $
  622. X# Revision 3.3  1991/09/09  16:33:23  barnett
  623. X# Minor bug fix release
  624. X#
  625. X# Revision 3.2  1991/05/16  10:45:25  barnett
  626. X# Better support for System V machines
  627. X# Support for machines with read only text segments
  628. X#
  629. X# Revision 3.1  1991/02/25  22:09:52  barnett
  630. X# Fixed some portability problems
  631. X#
  632. X# Revision 2.1  1990/01/30  13:54:13  jeff
  633. X# Updated for release 2.1 Aplha.
  634. X#
  635. X# Revision 2.0  88/06/15  14:47:35  root
  636. X# Baseline release for net posting. ADR.
  637. X# 
  638. X#
  639. X#    James S. Schoner, Purdue University Computing Center,
  640. X#              West Lafayette, Indiana  47907
  641. X#
  642. X#    Copyright (c) 1985 by Purdue Research Foundation
  643. X#
  644. X#    All rights reserved.
  645. X#
  646. X
  647. INCLUDE =
  648. X
  649. X# where to install the binaries
  650. BINDIR          =    ../bin
  651. X
  652. OWNER = root
  653. GROUP = staff
  654. MODE = 755
  655. X# Important Compile flags are defined here
  656. X# DATA_RW - this is defined if your system allows string constants to 
  657. X#           be modifiable. If you have one of the following systems, I am told
  658. X#        you should NOT define it: (Thanks to rainer@flyer.uni-duisburg.de)
  659. X#             - A sun 3/60 using gcc
  660. X#         - A esix SysV PC  with gcc
  661. X#                - A HP9000/845 with cc
  662. X#         - Apollo/Domain with BSD4.3 environment
  663. X#           The default is to define it, because this is what earlier versions 
  664. X#           of Ease did.
  665. X#
  666. X# SYSV
  667. X#         If you have a system V machine, and have <string.h>
  668. X#        instead of <strings.h>, then define this
  669. X#
  670. X#OFLAGS=-DSYSV 
  671. OFLAGS=-DDATA_RW
  672. DEFS = ${OFLAGS}
  673. LIBS = -ll
  674. X# some people must remove the -O
  675. CFLAGS = -O ${DEFS} ${INCLUDE}
  676. CC = cc
  677. X#CC = gcc
  678. YACC = yacc 
  679. X#YACC = bison -y
  680. X
  681. LP = lpr
  682. LPFLAGS = -J"Ease Source"
  683. X
  684. X
  685. X# System V install different from BSD install sigh...
  686. X#INSTALL = install -c -m ${MODE} -o ${OWNER} -g ${GROUP}
  687. INSTALL=cp
  688. X
  689. X# Special Debug flags
  690. X# select this one to debug the grammar
  691. X#DEFS =-DYYDEBUG
  692. X# The following two lines are used with the SunOS malloc() debug package.
  693. X#DEFS = -DMALLOC_DEBUG    #  Part of the SunOS malloc package
  694. X#LIBS = /usr/lib/debug/malloc.o -ll
  695. CFLAGS = -g  ${DEFS} ${INCLUDE}
  696. X
  697. X
  698. HDR = symtab.h
  699. SRC = main.c emitcf.c errors.c idman.c strops.c symtab.c fixstrings.c
  700. LST = Makefile lexan.l parser.y ${HDR} ${SRC}
  701. DEP = parser.c lexan.c ${SRC}
  702. OBJ = parser.o lexan.o main.o emitcf.o errors.o idman.o strops.o symtab.o \
  703. X    fixstrings.o
  704. CFILES= $(SRC) $(DEP)
  705. X
  706. all: et
  707. X
  708. et: ${OBJ}
  709. X    ${CC} ${CFLAGS} -o et ${OBJ} ${LIBS}
  710. X
  711. clean: FRC
  712. X    rm -f et *.o lexan.c parser.c y.output yacc.acts yacc.tmp \
  713. X          lexdefs.h y.tab.h errs Makefile.bak y.output y.tab.c y.tok.h
  714. X
  715. depend:
  716. X    ${CC} -M ${CFLAGS} ${CFILES} | \
  717. X    sed -e ':loop' \
  718. X        -e 's/\.\.\/[^ /]*\/\.\./../' \
  719. X        -e 't loop' | \
  720. X    awk ' { if ($$1 != prev) { print rec; rec = $$0; prev = $$1; } \
  721. X        else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
  722. X               else rec = rec " " $$2 } } ; \
  723. X          END { print rec } ' > makedep
  724. X    echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep
  725. X    echo '$$r makedep' >>eddep
  726. X    echo 'w' >>eddep
  727. X    cp Makefile Makefile.bak
  728. X    ex - Makefile < eddep
  729. X    rm eddep makedep
  730. X
  731. install: et FRC
  732. X    ${INSTALL} et ${BINDIR}
  733. X    ${INSTALL} ease.sh ${BINDIR}/ease
  734. X
  735. X
  736. lint:   ${DEP} symtab.h FRC
  737. X    lint -hxn ${DEP}
  738. X
  739. print:  ${LST} FRC
  740. X    @pr -f ${LST} | ${LP} ${LPFLAGS}
  741. X
  742. spotless: clean FRC
  743. X    rcsclean ${LST}
  744. X
  745. y.tab.h parser.c: parser.y
  746. X    @rm -f parser.c
  747. X    ${YACC} -v -d parser.y
  748. X    sed 's/=yylex/=yyyylex/' < y.tab.c >parser.c
  749. X
  750. X# the following dummy rule is because of the results of 'make depend'
  751. X# However, under SunOS Make - it complains. You may have to comment it out
  752. X./lexdefs.h:    lexdefs.h
  753. X
  754. lexdefs.h:    y.tab.h
  755. X    -(cmp -s y.tab.h lexdefs.h || cp y.tab.h lexdefs.h)
  756. X
  757. lexan.c: lexan.l
  758. X
  759. parser.o: y.tok.h
  760. y.tok.h:    y.tab.h
  761. X    grep '^#.*define' y.tab.h |\
  762. X    sed 's/^# define \([^ ]*\) [^ ]*$$/    "\1",/' >y.tok.h
  763. X
  764. X${HDR} ${SRC} lexan.l parser.y:
  765. X    co $@
  766. X
  767. XFRC:
  768. X
  769. X
  770. X# DO NOT DELETE THIS LINE -- make depend uses it
  771. X
  772. main.o: main.c fixstrings.h 
  773. emitcf.o: emitcf.c  symtab.h fixstrings.h
  774. errors.o: errors.c fixstrings.h
  775. idman.o: idman.c  symtab.h fixstrings.h
  776. strops.o: strops.c fixstrings.h 
  777. strops.o: symtab.h
  778. symtab.o: symtab.c fixstrings.h 
  779. symtab.o: symtab.h
  780. fixstrings.o: fixstrings.c 
  781. parser.o: parser.c fixstrings.h  symtab.h
  782. lexan.o: lexan.c  fixstrings.h symtab.h lexdefs.h
  783. main.o: main.c fixstrings.h 
  784. emitcf.o: emitcf.c  symtab.h fixstrings.h
  785. errors.o: errors.c fixstrings.h
  786. idman.o: idman.c  symtab.h fixstrings.h
  787. strops.o: strops.c fixstrings.h 
  788. strops.o: symtab.h
  789. symtab.o: symtab.c fixstrings.h 
  790. symtab.o: symtab.h
  791. fixstrings.o: fixstrings.c 
  792. X
  793. X
  794. X
  795. X
  796. X
  797. X
  798. X
  799. X
  800. END_OF_FILE
  801. if test 4585 -ne `wc -c <'src/Makefile'`; then
  802.     echo shar: \"'src/Makefile'\" unpacked with wrong size!
  803. fi
  804. # end of 'src/Makefile'
  805. fi
  806. if test -f 'src/ease.sh' -a "${1}" != "-c" ; then 
  807.   echo shar: Will not clobber existing file \"'src/ease.sh'\"
  808. else
  809. echo shar: Extracting \"'src/ease.sh'\" \(3735 characters\)
  810. sed "s/^X//" >'src/ease.sh' <<'END_OF_FILE'
  811. X#! /bin/sh
  812. X#
  813. X#  ease - front end for the ease translator (et).
  814. X#
  815. X#  This sh script simplifies the task of calling "et" with the proper flags.
  816. X#
  817. X#  It also defines a VERSION macro, known to cpp when preprocessing the
  818. X#  input to et.  This allows you to automatically embed the RCS version
  819. X#  number of your config file into the generated sendmail.cf. 
  820. X#
  821. X#  For example, if your ease input file contains the RCS version string
  822. X#    $Revision: 1.7 $
  823. X#  and the lines
  824. X#    define ("Received:",
  825. X#        "by ${m_oname} (${VERSION})"
  826. X#        ifset (m_shostname, " from ${m_shostname} ") "for ${m_ruser}"
  827. X#  then your sendmail.cf will define the "Received:" header line so that
  828. X#  it contains the RCS version number of the ease input file.  This version
  829. X#  number will ultimately be stamped into the header of every message which
  830. X#  flows though this sendmail, thus allowing you to see at a glance whether
  831. X#  some problem was due to an out-of-date sendmail.cf.
  832. X#
  833. X#  At our site, the "Received:" header lines thus have the following form:
  834. X#
  835. X#    Received: by isis.tc.fluke.COM (version 2.46)
  836. X#        from argv.tc.fluke.COM for jeff
  837. X#        id AA10285; Wed, 21 Feb 90 17:28:43 PST
  838. X#    Received: by argv.tc.fluke.COM (version 2.46)
  839. X#        for jeff@isis
  840. X#        id AA06739; Wed, 21 Feb 90 17:28:39 PST
  841. X#
  842. X#  This makes it a little easier to track down problems in networks comprising
  843. X#  dozens or hundreds of machines.
  844. X#
  845. X# $Source: /home/kreskin/u0/barnett/Src/ease/src/RCS/ease.sh,v $
  846. X# $Locker:  $
  847. X#
  848. X# $Revision: 1.7 $
  849. X# Check-in $Date: 1991/05/16 10:45:25 $
  850. X# $State: Exp $
  851. X#
  852. X# $Author: barnett $
  853. X#
  854. X# $Log: ease.sh,v $
  855. X# Revision 1.7  1991/05/16  10:45:25  barnett
  856. X# Better support for System V machines
  857. X# Support for machines with read only text segments
  858. X#
  859. X# Revision 1.6  1990/05/07  11:15:04  jeff
  860. X# Add support for the "-q" flag added to ease.
  861. X#
  862. X# Version 1.5  90/02/22  15:51:12  jeff
  863. X# Improved the comments in preparation for netwide release.
  864. X# 
  865. X# Version 1.4  88/11/18  11:24:12  jeff
  866. X# RCS mangled the previous change; try it again.  (It saw something that
  867. X# looked like a keyword to it, so it expanded the token.  Yuck.)
  868. X# 
  869. X# Version 1.3  88/11/18  11:20:52  jeff
  870. X# Change the VERSION macro from the date to the RCS revision of the
  871. X# config.ease file.
  872. X# 
  873. X# Version 1.2  87/04/13  16:56:29  jeff
  874. X# Change argument parsing to accomodate the new -C flag.
  875. X# 
  876. X# Version 1.1  87/04/08  12:20:58  jeff
  877. X# Initial version
  878. X# 
  879. X#
  880. X# @(#)FLUKE source file: $Header: /home/kreskin/u0/barnett/Src/ease/src/RCS/ease.sh,v 1.7 1991/05/16 10:45:25 barnett Exp $
  881. X
  882. PATH=.:/bin:/usr/bin:/usr/ucb:/usr/local/bin
  883. export PATH
  884. X
  885. echo    "#"
  886. echo    "#   Compiled via: $0 $*"
  887. echo    "# From directory: `pwd`"
  888. echo    "#           Date: `date`"
  889. echo    "#"
  890. echo    "# This file was produced by the \"ease\" translator."
  891. echo    "# You probably shouldn't edit it, since changes will be lost"
  892. echo    "# the next time that ease is run.  Instead, edit the source file"
  893. echo    "# located in the directory named above."
  894. echo    "#"
  895. X
  896. cppflags=
  897. etflags='-q'
  898. CPP='cc -E'
  899. X
  900. X
  901. for i in ${1+"$@"} ;do
  902. X    case "$1" in
  903. X    '')    break;;
  904. X    -C)    etflags="${etflags-} $1";;
  905. X    -D*)    cppflags="$cppflags $1";;
  906. X    *)    file="$1";;
  907. X    esac
  908. X    shift
  909. done
  910. X
  911. X#
  912. X#  Extract the RCS "Revision" string from the ease input file, and
  913. X#  use it to define the VERSION symbol to cpp.
  914. X#
  915. X#  If you maintain your ease input file with SCCS, the appropriate change
  916. X#  should be simple.
  917. X#
  918. Rev=`fgrep 'Revision:' $file | sed -e 's/^.*Revision:[     ]*\([^     ]*\).*/\1/'`
  919. X
  920. X# The sed commands delete empty comment lines and those preprocessor output
  921. X# lines which indicate the linenumber and filename.
  922. X$CPP -DVERSION=\"version\ $Rev\" $cppflags $file |
  923. X    et $etflags |
  924. X    sed -e '/^# *$/d' \
  925. X    -e '/^#[     ]*[0123456789][0123456789]*[     ]*".*"[     ]*$/d'
  926. END_OF_FILE
  927. if test 3735 -ne `wc -c <'src/ease.sh'`; then
  928.     echo shar: \"'src/ease.sh'\" unpacked with wrong size!
  929. fi
  930. # end of 'src/ease.sh'
  931. fi
  932. if test -f 'src/errors.c' -a "${1}" != "-c" ; then 
  933.   echo shar: Will not clobber existing file \"'src/errors.c'\"
  934. else
  935. echo shar: Extracting \"'src/errors.c'\" \(5256 characters\)
  936. sed "s/^X//" >'src/errors.c' <<'END_OF_FILE'
  937. X#ifdef FLUKE
  938. X# ifndef LINT
  939. X    static char RCSid[] = "@(#)FLUKE  $Header: /tmp_mnt/home/kreskin/u0/barnett/Src/Ease/ease/src/RCS/errors.c,v 2.3 1991/09/09 16:33:23 barnett Exp $";
  940. X# endif LINT
  941. X#endif FLUKE
  942. X
  943. X/*
  944. X *      errors.c   -- Contains error initialization and reporting routines.
  945. X *
  946. X *      author     -- James S. Schoner, Purdue University Computing Center,
  947. X *                        West Lafayette, Indiana  47907
  948. X *
  949. X *      date       -- July 9, 1985
  950. X *
  951. X *    Copyright (c) 1985 by Purdue Research Foundation
  952. X *
  953. X *    All rights reserved.
  954. X *
  955. X * $Log: errors.c,v $
  956. X * Revision 2.3  1991/09/09  16:33:23  barnett
  957. X * Minor bug fix release
  958. X *
  959. X * Revision 2.2  1991/05/16  10:45:25  barnett
  960. X * Better support for System V machines
  961. X * Support for machines with read only text segments
  962. X *
  963. X * Revision 2.1  1990/01/30  14:17:29  jeff
  964. X * Bruce Barnett - extensions for SunOS/Ultrix.
  965. X *
  966. X * Revision 2.0  88/06/15  14:41:10  root
  967. X * Baseline release for net posting. ADR.
  968. X */
  969. X
  970. X#include <stdio.h>
  971. X#include "fixstrings.h"
  972. X#include <ctype.h>
  973. extern int  ErrorCount;     /* error count                   */
  974. extern char FNbuf[];     /* input file name              */
  975. extern int  Lcount;     /* line count                    */
  976. XFILE *DIAGf = {stderr};  /* file for diagnostic output */
  977. extern char yytext[];    /* current token */
  978. extern int yyleng;    /* and it's length */
  979. extern int    yylineno;    /* current input line number */
  980. extern char *infile;        /* input file name */
  981. static char *source;
  982. X
  983. X/*
  984. X * yywhere() -- input position for yyparse()
  985. X * from Schreiner and Friedman's book on compiler construction
  986. X */
  987. void
  988. yywhere()     /* position stamp */
  989. X{
  990. X    char    colon = 0;    /* flag */
  991. X    if (source && *source && strcmp(source,"\"\"")) {
  992. X    char    *cp = source;
  993. X    int    len = strlen(source);
  994. X    
  995. X    if (*cp == '"')
  996. X      ++cp, len -= 2;
  997. X    if (strlen(cp, "./", 2) == 0)
  998. X      cp += 2, len -= 2;
  999. X    if (len > 0 )
  1000. X      fprintf(DIAGf, "\"%.*s\"", len, cp);
  1001. X    colon = 1;
  1002. X    }     else if (infile && strcmp(infile,"-")) {
  1003. X      fprintf(DIAGf, "\"%s\"",infile);
  1004. X      colon = 1;
  1005. X      }
  1006. X    if (yylineno > 0 ) {
  1007. X    if (colon)
  1008. X      fputs(", ",DIAGf);
  1009. X    fprintf(DIAGf, "line %d",
  1010. X        yylineno - (*yytext == '\n' || ! *yytext));
  1011. X    colon = 1;
  1012. X/*    if ((yylineno - (*yytext == '\n' || ! *yytext)) != Lcount)
  1013. X      fprintf(DIAGf, "?%d:?", Lcount); */
  1014. X    }
  1015. X    if (*yytext) {
  1016. X    register int i;
  1017. X    for (i=0;i<20;++i)
  1018. X      if (!yytext[i] || yytext[i] == '\n')
  1019. X        break;
  1020. X    if (i) {
  1021. X        if (colon)
  1022. X          putc(' ',DIAGf);
  1023. X        fprintf(DIAGf, "near \"%.*s\"",i,yytext);
  1024. X        colon = 1;
  1025. X    }
  1026. X    }
  1027. X    if (colon)
  1028. X      fputs(": ",DIAGf);
  1029. X    fflush(DIAGf);
  1030. X    fflush(stdout);
  1031. X    fflush(stderr); /* just to make sure */
  1032. X}
  1033. X
  1034. X
  1035. X/*
  1036. X *    yymark - keep track of source file and line number 
  1037. X */
  1038. X
  1039. void
  1040. yymark()    /* retreive from '# digit text' */
  1041. X{
  1042. X    if (source)
  1043. X      cfree(source); 
  1044. X    source = (char *) calloc(yyleng,sizeof(char));
  1045. X    if (source) {
  1046. X      sscanf(yytext, "# %d%s",&yylineno, source);
  1047. X/*      fprintf(stderr,"source = '%s' on %s",source,yytext); */
  1048. X      Lcount = yylineno;
  1049. X      if (strcmp(source,"\"\""))
  1050. X    strcpy(FNbuf,source);
  1051. X      else if ( infile && strcmp(infile,"-"))
  1052. X    sprintf(FNbuf,"\"%s\"",infile);
  1053. X/*      fprintf(stderr,"FNbuf = '%s', infile = '%s'\n",FNbuf,infile); */
  1054. X           
  1055. X  }
  1056. X}
  1057. X
  1058. X
  1059. X
  1060. X/*
  1061. X *    yyerror () -- Prints source file name (FNbuf), line number (Lcount),
  1062. X *              and error message (sbErr) for each invokation.
  1063. X *              it also prints out a message where the error is.
  1064. X *
  1065. X */
  1066. void
  1067. yyerror (sbErr)
  1068. char *sbErr;
  1069. X{
  1070. X    extern int yynerrs;
  1071. X    ++ErrorCount;
  1072. X    yywhere();
  1073. X/*    fprintf(DIAGf, " %s\t[error %d]\n", sbErr, ErrorCount); */
  1074. X    fprintf(DIAGf, " %s\n", sbErr);
  1075. X/* yynerrs is the number of yacc errors, ErrorCount is larger */
  1076. X}
  1077. X
  1078. X
  1079. X
  1080. X/*
  1081. X *    ErrorReport () -- Prints source file name (FNbuf), line number (Lcount),
  1082. X *              and error message (sbErr) for each invokation.
  1083. X *
  1084. X */
  1085. void
  1086. XErrorReport (sbErr)
  1087. char *sbErr;
  1088. X{
  1089. X/*    fprintf (DIAGf, "%s, line %d: %s", FNbuf, Lcount, sbErr);
  1090. X    ErrorCount++; */
  1091. X    yyerror(sbErr);
  1092. X}
  1093. X
  1094. X
  1095. X/*
  1096. X *    FatalError () -- Translator fatal error routine which prints 
  1097. X *             error message (sbErr) and an argument (sbArg).
  1098. X *
  1099. X */
  1100. void
  1101. XFatalError (sbErr, sbArg)
  1102. char *sbErr,
  1103. X     *sbArg;
  1104. X{
  1105. X    fprintf (DIAGf, "%s, line %d: Fatal Error In Translator: %s %s\n", 
  1106. X         FNbuf, Lcount, sbErr, sbArg); 
  1107. X    fflush(stderr);
  1108. X    exit (1);
  1109. X}
  1110. X
  1111. X
  1112. X/*
  1113. X *    PrintError () -- Prints source file name (FNbuf), line number
  1114. X *             (cline), error message (sbErr), and argument
  1115. X *             (sbArg) for each invokation.
  1116. X *
  1117. X */
  1118. void
  1119. PrintError (sbErr, sbArg)
  1120. char *sbErr;
  1121. char *sbArg;
  1122. X{
  1123. X    char    Ebuffer[1000];
  1124. X    sprintf(Ebuffer,sbErr,sbArg);
  1125. X    yyerror(Ebuffer);
  1126. X/*    fprintf (DIAGf, "%s, line %d: %s %s.\n", FNbuf, Lcount, sbErr, sbArg);
  1127. X    ErrorCount++; */
  1128. X}
  1129. X
  1130. X
  1131. X/*
  1132. X *    PrintWarning () -- Prints a warning message with source file
  1133. X *               name (FNbuf), line number (Lcount), warning
  1134. X *               (sbWarn), and a possible identifier (sbID).
  1135. X *
  1136. X */
  1137. void
  1138. PrintWarning (sbWarn, sbID)
  1139. char *sbWarn;
  1140. char *sbID;
  1141. X{
  1142. X/*    fprintf (DIAGf, "%s, line %d: Warning: ", FNbuf, Lcount); */
  1143. X        yywhere();
  1144. X    fprintf(DIAGf,"Warning: ");
  1145. X    if (sbID != NULL)
  1146. X        fprintf (DIAGf, sbWarn, sbID);
  1147. X    else
  1148. X        fprintf (DIAGf, sbWarn);
  1149. X}
  1150. X
  1151. X
  1152. X/*
  1153. X *    InitError () -- Initialize line count (Lcount) to one and error count
  1154. X *                (ErrorCount) to zero.
  1155. X *
  1156. X */
  1157. void
  1158. InitError ()
  1159. X{
  1160. X    Lcount     = 1;
  1161. X    ErrorCount = 0;
  1162. X}
  1163. END_OF_FILE
  1164. if test 5256 -ne `wc -c <'src/errors.c'`; then
  1165.     echo shar: \"'src/errors.c'\" unpacked with wrong size!
  1166. fi
  1167. # end of 'src/errors.c'
  1168. fi
  1169. if test -f 'src/idman.c' -a "${1}" != "-c" ; then 
  1170.   echo shar: Will not clobber existing file \"'src/idman.c'\"
  1171. else
  1172. echo shar: Extracting \"'src/idman.c'\" \(6904 characters\)
  1173. sed "s/^X//" >'src/idman.c' <<'END_OF_FILE'
  1174. X#ifdef FLUKE
  1175. X# ifndef LINT
  1176. X    static char RCSid[] = "@(#)FLUKE  $Header: /home/kreskin/u0/barnett/Src/Ease/ease/src/RCS/idman.c,v 3.2 1991/10/15 17:02:04 barnett Exp $";
  1177. X# endif LINT
  1178. X#endif FLUKE
  1179. X
  1180. X/*
  1181. X *      idman.c    -- Contains routines for manipulating identifiers and their
  1182. X *           symbolic associations.
  1183. X *
  1184. X *      author    -- James S. Schoner, Purdue University Computing Center,
  1185. X *                     West Lafayette, Indiana  47907
  1186. X *
  1187. X *      date    -- July 9, 1985
  1188. X *
  1189. X *    Copyright (c) 1985 by Purdue Research Foundation
  1190. X *
  1191. X *    All rights reserved.
  1192. X *
  1193. X * $Log: idman.c,v $
  1194. X * Revision 3.2  1991/10/15  17:02:04  barnett
  1195. X * Detect if (one_or_more) next ($2) error
  1196. X *
  1197. X * Revision 3.1  1991/02/25  22:09:52  barnett
  1198. X * Fixed some portability problems
  1199. X *
  1200. X * Revision 3.0  1991/02/22  18:50:27  barnett
  1201. X * Added support for HP/UX and IDA sendmail.
  1202. X *
  1203. X * Revision 2.1  1990/01/30  14:33:52  jeff
  1204. X * Bruce Barnett - changed UniqMac.
  1205. X *
  1206. X * Revision 2.0  88/06/15  14:42:14  root
  1207. X * Baseline release for net posting. ADR.
  1208. X */
  1209. X
  1210. X#include <stdio.h>
  1211. X#include <ctype.h>
  1212. X#include "symtab.h"
  1213. X#include "fixstrings.h"
  1214. X
  1215. extern struct he *LookupSymbol ();
  1216. extern void      FatalError (),
  1217. X          ErrorReport (),
  1218. X          PrintWarning (),
  1219. X          PrintError ();
  1220. extern char *      malloc ();
  1221. extern short number_of_fields;    /* number of fields on a ruleset */
  1222. X
  1223. char    IDused[] = "                          "; /* 26 blanks */
  1224. X/*
  1225. X *    UniqMac () -- Assigns and returns a unique one-character macro
  1226. X *              name (upper-case) for an Ease macro name.
  1227. X *
  1228. X *    Bruce Barnett:
  1229. X *    Special enhancement - if idval is a single character,
  1230. X *    and the corresponding letter has not been assigned,
  1231. X *    Make the idc character the same as the macro name 
  1232. X *
  1233. X *    This makes it nice to test cfc/ease completeness.
  1234. X *    Also makes reading the ease output easier.
  1235. X *
  1236. X */
  1237. char
  1238. UniqMac (phe)
  1239. struct he *phe;        /* symbol table entry for Ease macro */
  1240. X{
  1241. X    short i;
  1242. X
  1243. X    if ((strlen(phe->psb) == 1) && 
  1244. X    isupper(*(phe->psb)) &&
  1245. X    IDused[*(phe->psb) - 'A'] == ' ' ) {
  1246. X    IDused[*(phe->psb) - 'A'] = (phe->idval.idc) = *(phe->psb);
  1247. X    } else {
  1248. X    for (i=0;i<26 && IDused[i] != ' ';i++) 
  1249. X      ;    /* find first unused letter */
  1250. X    if (i==26) FatalError ("Too many macro names (26 max)", (char *) NULL);
  1251. X    IDused[i] = 
  1252. X      (phe->idval.idc) = 
  1253. X        'A' + i;
  1254. X    }
  1255. X    return (phe->idval.idc);
  1256. X}
  1257. X
  1258. X
  1259. X/*
  1260. X *    BindID () -- Binds either a ruleset or precedence identifier (phe) to
  1261. X *              an integer (vid).  The id type distinction is passed in
  1262. X *             the parameter idt.
  1263. X *
  1264. X */
  1265. void
  1266. BindID (phe, vid, idt)
  1267. register struct he *phe;    /* symbol table entry for an identifier    */
  1268. int vid;            /* value of the identifier           */
  1269. unsigned idt;            /* identifier type (ruleset or precedence) */
  1270. X{
  1271. X    if (ISTYPED(phe->idtype)) {    /* should be undefined */
  1272. X        PrintWarning ("Redeclaration of %s.\n", phe->psb);
  1273. X        phe->idtype = ID_UNTYPED;
  1274. X    }
  1275. X    phe->idtype |= idt;        /* make defined           */
  1276. X    if (ISRULESET(phe->idtype)) {
  1277. X        if (vid > VALRSNMAX) {
  1278. X            ErrorReport ("Ruleset number too large.\n");
  1279. X            return;
  1280. X        } else if (vid < 0) {
  1281. X            ErrorReport ("Ruleset number must be non-negative.\n");
  1282. X            return;
  1283. X        }
  1284. X        sprintf (phe->idval.rsn, "%d", vid);
  1285. X    } else 
  1286. X        phe->idval.prec = vid;
  1287. X}
  1288. X
  1289. X
  1290. X/*
  1291. X *    CheckRS () -- Checks validity of a ruleset identifier (phe) and 
  1292. X *              returns the ruleset string to which the identifier
  1293. X *              is bound.  If the ruleset identifier is invalid, the
  1294. X *              null string is returned.
  1295. X *
  1296. X */
  1297. char *
  1298. CheckRS (phe)
  1299. struct he *phe;        /* symbol table entry for ruleset identifier */
  1300. X{
  1301. X    if (!ISRULESET(phe->idtype)) {
  1302. X        if (!ISTYPED(phe->idtype))
  1303. X            PrintError ("Ruleset identifier not bound to a number: %s", phe->psb);
  1304. X        else
  1305. X            PrintError ("Identifier not of ruleset type: %s", phe->psb);
  1306. X        return (NULL);
  1307. X    } else
  1308. X        return (phe->idval.rsn);
  1309. X}
  1310. X
  1311. X
  1312. X/*
  1313. X *    MakeMac () -- Declare a macro name (pmac) as a class and/or macro type 
  1314. X *              (targtype) and return the unique cf character assigned 
  1315. X *              to it.
  1316. X *
  1317. X */
  1318. char
  1319. MakeMac (pmac, targtype)
  1320. register struct he *pmac;    /* symbol table entry for macro identifier */
  1321. unsigned targtype;        /* target declaration type for the macro   */
  1322. X{
  1323. X    /*
  1324. X     *    An Ease macro may be declared as both a singular macro and
  1325. X     *    a class macro.
  1326. X     *
  1327. X     */
  1328. X    if (ISMACRO(pmac->idtype) || ISCLASS(pmac->idtype)) {
  1329. X        pmac->idtype |= targtype;
  1330. X        return (pmac->idval.idc);
  1331. X    }
  1332. X    if (ISTYPED(pmac->idtype)) {    /* not a macro or class id */
  1333. X        PrintError ("Redeclaring or using as macro or class: %s", pmac->psb);
  1334. X        return ('\0');
  1335. X    }
  1336. X    pmac->idtype |= targtype;    /* previously untyped; declare here */
  1337. X    return (UniqMac (pmac));
  1338. X}
  1339. X    
  1340. X
  1341. X/*
  1342. X *    GetField () -- Returns a field type string given a field 
  1343. X *               identifier (fid).
  1344. X *
  1345. X */
  1346. char *
  1347. GetField (fid)
  1348. register struct he *fid;    /* field identifier */
  1349. X{
  1350. X    if (!ISFIELD(fid->idtype)) {
  1351. X        PrintError ("Field type not defined for %s", fid->psb);
  1352. X        return (NULL);
  1353. X    } else {
  1354. X        number_of_fields++;
  1355. X        return (fid->idval.fstring);
  1356. X    }
  1357. X}
  1358. X
  1359. X
  1360. X/*
  1361. X *    CheckMailer () -- Declares a mailer identifier (mid) as type mailer,
  1362. X *              checking that the identifier was not previously 
  1363. X *              declared a different type. 
  1364. X *
  1365. X */
  1366. char *
  1367. CheckMailer (mid)
  1368. register struct he *mid;
  1369. X{
  1370. X    if (ISTYPED (mid->idtype) && !ISMAILER (mid->idtype)) {
  1371. X        PrintError ("Redeclaration as mailer: %s", mid->psb);
  1372. X        return (NULL);
  1373. X    }
  1374. X    mid->idtype |= ID_MAILER;
  1375. X    return (mid->psb);
  1376. X}
  1377. X
  1378. X
  1379. X/*
  1380. X *    AssignType () -- Assigns to each field identifier in fidlist the
  1381. X *             type (in string form) fidtype.  This is accomplished
  1382. X *             by making each field identifier symbol table entry
  1383. X *             "point" to the type found in fidtype.
  1384. X *
  1385. X */
  1386. void
  1387. AssignType (fidlist, fidtype)
  1388. register char *fidlist;        /* field identifier list, blank separated */
  1389. char *fidtype;            /* field identifier type string          */
  1390. X{
  1391. X    register struct he *fid;    /* pointer to a field identifier  */
  1392. X    char *fres;            /* field type result string      */
  1393. X    register char *srch;        /* fidlist search pointer      */
  1394. X    char  sep;            /* fidlist separator character    */
  1395. X
  1396. X    fres = (char *) malloc (strlen (fidtype) + 1);
  1397. X    if (fres == NULL)
  1398. X        FatalError ("System out of string space in AssignType ()", (char *) NULL);
  1399. X    strcpy (fres, fidtype);        /* make clean copy of string type */
  1400. X
  1401. X    /*
  1402. X     *    Search for all field identifiers and make the type assignment. 
  1403. X      *
  1404. X     */
  1405. X    srch = fidlist;
  1406. X    while (*srch != '\0') {
  1407. X        while ((*++srch != ' ') && (*srch != '\0'))
  1408. X            /* null */ ;
  1409. X        if (*fidlist != '\0') {                /* found a field id       */
  1410. X            sep = *srch;
  1411. X            *srch = '\0';
  1412. X            fid = LookupSymbol (fidlist);    /* get symbol table entry */
  1413. X            if (ISFIELD(fid->idtype)) {
  1414. X                if (strcmp (fid->idval.fstring, fres))
  1415. X                    PrintWarning ("Redefinition of field type for %s.\n", fid->psb);
  1416. X            } else if (ISTYPED(fid->idtype)) {
  1417. X                PrintError ("Redeclaration of identifier as a field: %s", fid->psb);
  1418. X                return;
  1419. X            }
  1420. X            fid->idtype |= ID_FIELD;    /* type the identifier    */
  1421. X            fid->idval.fstring = fres;    /* type the field      */
  1422. X            if ((*srch = sep) != '\0')
  1423. X                fidlist = ++srch;
  1424. X        }
  1425. X    }
  1426. X}
  1427. END_OF_FILE
  1428. if test 6904 -ne `wc -c <'src/idman.c'`; then
  1429.     echo shar: \"'src/idman.c'\" unpacked with wrong size!
  1430. fi
  1431. # end of 'src/idman.c'
  1432. fi
  1433. if test -f 'src/lexan.patch' -a "${1}" != "-c" ; then 
  1434.   echo shar: Will not clobber existing file \"'src/lexan.patch'\"
  1435. else
  1436. echo shar: Extracting \"'src/lexan.patch'\" \(5320 characters\)
  1437. sed "s/^X//" >'src/lexan.patch' <<'END_OF_FILE'
  1438. X*** /home/kreskin/u0/barnett/Src/ease/src/lexan.l    Wed Mar  1 15:43:53 1989
  1439. X--- lexan.l    Mon May  7 14:12:53 1990
  1440. X***************
  1441. X*** 59,78 ****
  1442. X      static char linbuf[BUFSIZ], *pc = linbuf;
  1443. X      char c;
  1444. X  
  1445. X- 
  1446. X- 
  1447. X- 
  1448. X- 
  1449. X      /* initialize buffer: first call only */
  1450. X      if (*pc == '\0' && pc == linbuf) {
  1451. X          if (fgets(linbuf, BUFSIZ, yyin)==NULL)
  1452. X              return EOF;
  1453. X!                 if (linbuf[0] == '#' )
  1454. X!                     fprintf(yyout, "%s", linbuf);  /* echo input as comment */
  1455. X!                 else
  1456. X!                     fprintf(yyout, "# %s", linbuf);  /* echo input as comment */
  1457. X! 
  1458. X      }
  1459. X      c = *pc++;
  1460. X      if (c == '\n') {
  1461. X          pc = linbuf;
  1462. X--- 68,82 ----
  1463. X      static char linbuf[BUFSIZ], *pc = linbuf;
  1464. X      char c;
  1465. X  
  1466. X      /* initialize buffer: first call only */
  1467. X      if (*pc == '\0' && pc == linbuf) {
  1468. X          if (fgets(linbuf, BUFSIZ, yyin)==NULL)
  1469. X              return EOF;
  1470. X!         /* echo input as comment */
  1471. X!         if (EchoInputAsComments) {
  1472. X!             fprintf(yyout, "%s%s", (linbuf[0] == '#' ? "" : "# "), linbuf);
  1473. X          }
  1474. X+     }
  1475. X      c = *pc++;
  1476. X      if (c == '\n') {
  1477. X          pc = linbuf;
  1478. X***************
  1479. X*** 79,90 ****
  1480. X          if (fgets(linbuf, BUFSIZ, yyin) == NULL)
  1481. X              *pc = EOF;
  1482. X          else
  1483. X!             /* echo input as comment except cpp comments */
  1484. X!                     if (linbuf[0] == '#' )
  1485. X!                         fprintf(yyout, "%s", linbuf);  /* echo input as comment */
  1486. X!                     else
  1487. X!                         fprintf(yyout, "# %s", linbuf);  /* echo input as comment */
  1488. X      }
  1489. X      return c;
  1490. X  }
  1491. X  
  1492. X--- 83,94 ----
  1493. X          if (fgets(linbuf, BUFSIZ, yyin) == NULL)
  1494. X              *pc = EOF;
  1495. X          else
  1496. X!             /* echo input as comment (except cpp comments) */
  1497. X!             if (EchoInputAsComments) {
  1498. X!                 fprintf(yyout, "%s%s",
  1499. X!                 (linbuf[0] == '#' ? "" : "# "), linbuf);
  1500. X              }
  1501. X+     }
  1502. X      return c;
  1503. X  }
  1504. X  
  1505. X***************
  1506. X*** 103,109 ****
  1507. X      { "Path",        MPATH },
  1508. X      { "Recipient",        MRECIPIENT },
  1509. X      { "Sender",        MSENDER },
  1510. X-     { "asm",        ASM },
  1511. X      { "bind",        BIND },
  1512. X      { "canon",        CANON },
  1513. X      { "class",        CLASS },
  1514. X--- 107,112 ----
  1515. X***************
  1516. X*** 112,121 ****
  1517. X      { "d_interactive",    DOPTI },
  1518. X      { "d_queue",        DOPTQ },
  1519. X      { "define",        DEFINE },
  1520. X-     { "eval",        EVAL },
  1521. X      { "f_addrw",        CCFLAG },
  1522. X      { "f_arpa",        AAFLAG },
  1523. X-     { "f_bsmtp",        BBFLAG },    /* IDA */
  1524. X      { "f_date",        DDFLAG },
  1525. X      { "f_dot",        XXFLAG },
  1526. X      { "f_escape",        EEFLAG },
  1527. X--- 115,122 ----
  1528. X***************
  1529. X*** 125,136 ****
  1530. X      { "f_full",        XFLAG },
  1531. X      { "f_llimit",        LLFLAG },
  1532. X      { "f_locm",        LFLAG },
  1533. X-     { "f_mail11",        HHFLAG },
  1534. X      { "f_mesg",        MMFLAG },
  1535. X      { "f_mult",        MFLAG },
  1536. X      { "f_noreset",        SSFLAG },
  1537. X      { "f_noufrom",        NFLAG },
  1538. X-     { "f_relativize",    VVFLAG },
  1539. X      { "f_retsmtp",        PFLAG },
  1540. X      { "f_return",        PPFLAG },
  1541. X      { "f_rfrom",        RFLAG },
  1542. X--- 126,135 ----
  1543. X***************
  1544. X*** 159,171 ****
  1545. X      { "match",        MATCH },
  1546. X      { "next",        NEXT },
  1547. X      { "o_alias",        AAOPT },
  1548. X-     { "o_aliasfile",    YYOPT },
  1549. X      { "o_bsub",        BBOPT },
  1550. X      { "o_checkpoint",    CCOPT },
  1551. X      { "o_delivery",        DOPT },
  1552. X      { "o_dmuid",        UOPT },
  1553. X      { "o_dnet",        NNOPT },
  1554. X-     { "o_envelope",        SLOPT },
  1555. X      { "o_ewait",        AOPT },
  1556. X      { "o_flog",        SSOPT },
  1557. X      { "o_fsmtp",        HHOPT },
  1558. X--- 158,168 ----
  1559. X***************
  1560. X*** 174,183 ****
  1561. X      { "o_hformat",        OOPT },
  1562. X      { "o_loadnc",        XXOPT },
  1563. X      { "o_loadq",        XOPT },
  1564. X-     { "o_maxempty",        BOPT },
  1565. X-     { "o_maxhops",        HOPT },
  1566. X      { "o_newproc",        YYOPT },
  1567. X-     { "o_nfs",        RROPT },    /* SunOS 4.0 */
  1568. X      { "o_pmaster",        PPOPT },
  1569. X      { "o_prifactor",    ZOPT },
  1570. X      { "o_qdir",        QQOPT },
  1571. X--- 171,177 ----
  1572. X***************
  1573. X*** 200,209 ****
  1574. X      { "o_wizpass",        WWOPT },
  1575. X      { "options",        OPTIONS },
  1576. X      { "precedence",        PRECEDENCE },
  1577. X-     { "quote",        QUOTE },
  1578. X      { "readclass",        READCLASS },
  1579. X      { "resolve",        RESOLVE },
  1580. X-     { "resolved",        RESOLVED },
  1581. X      { "retry",        RETRY },
  1582. X      { "return",        RETURN },
  1583. X      { "ruleset",        RULESET },
  1584. X--- 194,201 ----
  1585. X***************
  1586. X*** 210,218 ****
  1587. X      { "trusted",        TRUSTED },
  1588. X      { "user",        USER },
  1589. X      { "while",        IF },
  1590. X-     { "ypalias",        YPALIAS },
  1591. X-     { "ypmap",        YPMAP },
  1592. X-     { "yppasswd",        YPPASSWD },
  1593. X  };
  1594. X  %}
  1595. X  
  1596. X--- 202,207 ----
  1597. X***************
  1598. X*** 221,231 ****
  1599. X  
  1600. X  [ \t\f]+            ;     /* discard whitepsace  */
  1601. X  [\n]                Lcount++;
  1602. X! ^\#[ \t]*[0-9]+[ \t]*\".*\"[ \t]*.*[\n]    {
  1603. X! /*                    sscanf (yytext, "%*c%d%s", &Lcount, FNbuf); */
  1604. X!                             yymark();
  1605. X                      }
  1606. X! [A-Za-z_][A-Za-z0-9_-]*        {
  1607. X                  register int l, h, m, r, c;
  1608. X  
  1609. X                  l = 0;
  1610. X--- 210,219 ----
  1611. X  
  1612. X  [ \t\f]+            ;     /* discard whitepsace  */
  1613. X  [\n]                Lcount++;
  1614. X! ^\#[ \t]*[0-9]+[ \t]*\".*\"[ \t]*[\n]    {
  1615. X!                     sscanf (yytext, "%*c%d%s", &Lcount, FNbuf);
  1616. X                      }
  1617. X! [A-Za-z][A-Za-z0-9_-]*        {
  1618. X                  register int l, h, m, r, c;
  1619. X  
  1620. X                  l = 0;
  1621. X***************
  1622. X*** 292,305 ****
  1623. X                          INch = input ();
  1624. X                  }
  1625. X                  }
  1626. X- "/"                return (SLASH);
  1627. X  [\\]?.                {
  1628. X                  if (RMatch) {    /* in rulesets, return literal character */
  1629. X                      yylval.ival = (yytext[0] == '\\') ? yytext[1] : yytext[0];
  1630. X                      return (SEPCHAR);
  1631. X- 
  1632. X                  } else {
  1633. X!                     PrintError ("Illegal delimiter character: (octal code) \\%03o", *yytext);
  1634. X                  }
  1635. X                  }
  1636. X  %%
  1637. X--- 280,292 ----
  1638. X                          INch = input ();
  1639. X                  }
  1640. X                  }
  1641. X  [\\]?.                {
  1642. X                  if (RMatch) {    /* in rulesets, return literal character */
  1643. X                      yylval.ival = (yytext[0] == '\\') ? yytext[1] : yytext[0];
  1644. X                      return (SEPCHAR);
  1645. X                  } else {
  1646. X!                     ErrorReport ("Illegal delimiter character");
  1647. X!                     printf (": (octal code) \\%03o\n", *yytext);
  1648. X                  }
  1649. X                  }
  1650. X  %%
  1651. END_OF_FILE
  1652. if test 5320 -ne `wc -c <'src/lexan.patch'`; then
  1653.     echo shar: \"'src/lexan.patch'\" unpacked with wrong size!
  1654. fi
  1655. # end of 'src/lexan.patch'
  1656. fi
  1657. if test -f 'src/symtab.c' -a "${1}" != "-c" ; then 
  1658.   echo shar: Will not clobber existing file \"'src/symtab.c'\"
  1659. else
  1660. echo shar: Extracting \"'src/symtab.c'\" \(6799 characters\)
  1661. sed "s/^X//" >'src/symtab.c' <<'END_OF_FILE'
  1662. X#ifdef FLUKE
  1663. X# ifndef LINT
  1664. X    static char RCSid[] = "@(#)FLUKE  $Header: /tmp_mnt/home/kreskin/u0/barnett/Src/Ease/ease/src/RCS/symtab.c,v 3.1 1991/09/09 16:33:23 barnett Exp $";
  1665. X# endif LINT
  1666. X#endif FLUKE
  1667. X
  1668. X/*
  1669. X *      symtab.c   -- Contains Ease Translator symbol table routines.
  1670. X *
  1671. X *      author     -- James S. Schoner, Purdue University Computing Center,
  1672. X *                        West Lafayette, Indiana  47907
  1673. X *
  1674. X *      date       -- July 9, 1985
  1675. X *
  1676. X *    Copyright (c) 1985 by Purdue Research Foundation
  1677. X *
  1678. X *    All rights reserved.
  1679. X *
  1680. X * $Log: symtab.c,v $
  1681. X * Revision 3.1  1991/09/09  16:33:23  barnett
  1682. X * Minor bug fix release
  1683. X *
  1684. X * Revision 3.0  1991/02/22  18:50:27  barnett
  1685. X * Added support for HP/UX and IDA sendmail.
  1686. X *
  1687. X * Revision 2.1  1990/01/30  15:55:54  jeff
  1688. X * SunOS/Ultrix/Ida additions Jan 25 1988 Bruce Barnett
  1689. X *
  1690. X * Revision 2.0  88/06/15  14:43:04  root
  1691. X * Baseline release for net posting. ADR.
  1692. X */
  1693. X
  1694. X#include "fixstrings.h"
  1695. X#include <stdio.h>
  1696. X#include <ctype.h>
  1697. X#include "symtab.h"
  1698. X
  1699. X#define ERRORMAILER "error"        /* predefined error mailer name */
  1700. X#define ERRORMAILERUC "ERROR"        /* predefined ERROR mailer name */
  1701. X
  1702. extern void FatalError (),
  1703. X        PrintWarning ();
  1704. X
  1705. struct he *LookupSymbol ();
  1706. X
  1707. struct Defmac {                /* predefined macro struct def  */
  1708. X    char *macname;
  1709. X    char  macrep;
  1710. X};
  1711. X
  1712. static struct he *SymTab[SST];        /* hash table base array        */
  1713. static struct Defmac MacDefs[] = {    /* predefined macros            */
  1714. X            {"m_smtp",    'e'},
  1715. X            {"m_oname",    'j'},
  1716. X            {"m_uucpname",    'k'}, /* IDA */
  1717. X            {"m_ufrom",    'l'},
  1718. X            {"m_daemon",    'n'},
  1719. X            {"m_domain",    'm'},    /* SunOS */
  1720. X            {"m_addrops",    'o'},
  1721. X            {"m_defaddr",    'q'},
  1722. X            {"m_sitename",    'w'},
  1723. X            {"m_odate",    'a'},
  1724. X            {"m_adate",    'b'},
  1725. X            {"m_hops",    'c'},
  1726. X            {"m_udate",    'd'},
  1727. X            {"m_saddr",    'f'},
  1728. X            {"m_sreladdr",    'g'},
  1729. X            {"m_rhost",    'h'},
  1730. X            {"m_qid",    'i'},
  1731. X            {"m_pid",    'p'},
  1732. X            {"m_protocol",    'r'},
  1733. X            {"m_shostname", 's'},
  1734. X            {"m_ctime",    't'},
  1735. X            {"m_ruser",    'u'},
  1736. X            {"m_version",    'v'},
  1737. X            {"m_sname",    'x'},
  1738. X            {"m_stty",    'y'},
  1739. X            {"m_rhdir",    'z'},
  1740. X            {"sentinel",    '\0'}
  1741. X};
  1742. X
  1743. X/* FLUKE jps 28-apr-86 - Install some wired-in class names */
  1744. static struct Defmac ClassDefs[] = {    /* predefined classes */
  1745. X            {"c_myname",    'w'},
  1746. X            {"c_mydomain",    'm'},
  1747. X            {"class_sentinel",    '\0'}
  1748. X};
  1749. X
  1750. X/*
  1751. X *    DefScan () -- Scan symbol table to find macros, classes, mailers, 
  1752. X *              and rulesets which have been referenced or declared, but
  1753. X *              not defined.  A warning is printed for each such 
  1754. X *              occurence.  This routine is usually called at the end
  1755. X *              of a successful Ease translation.
  1756. X *
  1757. X */
  1758. void
  1759. DefScan ()
  1760. X{
  1761. X    register int stindex;        /* symbol table hash index   */
  1762. X    register struct he *hcsearch;    /* hash chain search pointer */
  1763. X
  1764. X    for (stindex = 0; stindex < SST; stindex++) {
  1765. X        if ((hcsearch = SymTab[stindex]) != NULL)
  1766. X            while (hcsearch != NULL) {
  1767. X                if ((ISMACRO(hcsearch->idtype) && 
  1768. X                     isupper(hcsearch->idval.idc)) &&
  1769. X                     !ISMACRO(hcsearch->idd))
  1770. X                    PrintWarning ("Macro not defined: %s\n", hcsearch->psb);
  1771. X#ifdef notdef
  1772. X                if (ISCLASS(hcsearch->idtype) && !ISCLASS(hcsearch->idd))
  1773. X#else
  1774. X                /* FLUKE jps 28-apr-86 */
  1775. X                /* print warnings for UPPER CASE names only */
  1776. X                if (ISCLASS(hcsearch->idtype) &&
  1777. X                    isupper(hcsearch->idval.idc) &&
  1778. X                    !ISCLASS(hcsearch->idd))
  1779. X#endif
  1780. X                    PrintWarning ("Class not defined: %s\n", hcsearch->psb);
  1781. X                if (ISMAILER(hcsearch->idtype) && !ISMAILER(hcsearch->idd) && (strcmp(hcsearch->psb,"LOCAL")))
  1782. X                    PrintWarning ("Mailer not defined: %s\n", hcsearch->psb);
  1783. X                if (ISRULESET(hcsearch->idtype) && !ISRULESET(hcsearch->idd))
  1784. X                    PrintWarning ("Ruleset not defined: %s\n", hcsearch->psb);
  1785. X                hcsearch = hcsearch->phe;
  1786. X            }
  1787. X    }
  1788. X}
  1789. X                     
  1790. X
  1791. X/*
  1792. X *    InitSymbolTable () -- Invoked by main () to initialize the symbol table.
  1793. X *
  1794. X */
  1795. void
  1796. InitSymbolTable ()
  1797. X{
  1798. X    int i;
  1799. X
  1800. X    for (i = 0; i < SST; i++)        /* initialize base array */
  1801. X        SymTab[i] = NULL;
  1802. X}
  1803. X
  1804. X
  1805. X/*
  1806. X *    PreLoad () -- Invoked by main () to preload special macro names 
  1807. X *              and mailer declarations.
  1808. X *
  1809. X */
  1810. void
  1811. PreLoad ()
  1812. X{
  1813. X    struct Defmac *macptr;
  1814. X    struct he     *symptr;
  1815. X
  1816. X    /* preload special (lower-case) macros */
  1817. X    for (macptr = &MacDefs[0]; (*macptr).macrep != '\0'; macptr++) {
  1818. X        symptr = LookupSymbol ((*macptr).macname);
  1819. X        symptr->idtype |= ID_MACRO;
  1820. X        symptr->idval.idc = (*macptr).macrep;
  1821. X    }
  1822. X
  1823. X    /* preload special (lower-case) classes */
  1824. X    for (macptr = &ClassDefs[0]; (*macptr).macrep != '\0'; macptr++) {
  1825. X        symptr = LookupSymbol ((*macptr).macname);
  1826. X        symptr->idtype |= ID_CLASS;
  1827. X        symptr->idval.idc = (*macptr).macrep;
  1828. X    }
  1829. X
  1830. X    /* preload error mailer declaration */
  1831. X    symptr = LookupSymbol (ERRORMAILER);
  1832. X    symptr->idtype |= ID_MAILER;
  1833. X    symptr->idd |= ID_MAILER;
  1834. X
  1835. X    /* preload ERROR mailer declaration */
  1836. X    symptr = LookupSymbol (ERRORMAILERUC);
  1837. X    symptr->idtype |= ID_MAILER;
  1838. X    symptr->idd |= ID_MAILER;
  1839. X}
  1840. X    
  1841. X
  1842. X/*
  1843. X *    LookupSymbol () -- Returns a pointer to the hash entry already 
  1844. X *               existing, or newly created, which corresponds 
  1845. X *               to string sb.
  1846. X *
  1847. X */
  1848. struct he *
  1849. LookupSymbol (sb)
  1850. char sb[];            /* string buffer containing identifier */
  1851. X{
  1852. X    struct he *phe;        /* hash entry search pointer  */
  1853. X    int      hc;        /* hash code of sb identifier */
  1854. X    extern char *malloc ();
  1855. X
  1856. X    phe = SymTab[hc = HashCode (sb)];
  1857. X    while (phe != NULL)            /* find hash entry for sb */
  1858. X        if (!strcmp (phe->psb, sb))
  1859. X            return (phe);
  1860. X        else
  1861. X            phe = phe->phe;
  1862. X    /* make new symbol table entry */
  1863. X    if ((phe = (struct he *) malloc (sizeof (struct he))) == NULL)
  1864. X        FatalError ("System out of space in LookupSymbol ()", (char *) NULL);
  1865. X    if ((phe->psb = (char *) malloc (strlen (sb) + 1)) == NULL)
  1866. X        FatalError ("System out of space in LookupSymbol ()", (char *) NULL);
  1867. X    strcpy (phe->psb, sb);
  1868. X    phe->idval.idc = '\0';
  1869. X    phe->idtype = ID_UNTYPED;
  1870. X    phe->idd = ID_UNTYPED;
  1871. X    phe->phe = SymTab[hc];
  1872. X    return (SymTab[hc] = phe);
  1873. X}
  1874. X
  1875. X
  1876. X/*
  1877. X *    RemoveSymbol () -- Removes the symbol table entry phe from the 
  1878. X *               symbol table.
  1879. X *
  1880. X */
  1881. void
  1882. RemoveSymbol (phe)
  1883. struct he *phe;       /* pointer to hash entry to be removed from symbol table */
  1884. X{
  1885. X    int hc;               /* hash code of entry phe       */
  1886. X    struct he *sphe;    /* search pointer for entry phe */
  1887. X
  1888. X    if (phe == NULL)
  1889. X        return;
  1890. X    else {            /* search and remove entry phe  */
  1891. X        sphe = SymTab[hc = HashCode (phe->psb)];
  1892. X        free (phe->psb);
  1893. X        if (sphe == phe)
  1894. X            SymTab[hc] = phe->phe;
  1895. X        else
  1896. X            while (sphe != NULL)
  1897. X                if (sphe->phe == phe) {
  1898. X                    sphe->phe = phe->phe;
  1899. X                    return;
  1900. X                } else
  1901. X                    sphe = sphe->phe;
  1902. X    }
  1903. X}
  1904. X
  1905. X
  1906. X/*
  1907. X *    HashCode () -- Returns the hash code of the string in sb by adding 
  1908. X *               the character values and applying mod by the hash 
  1909. X *               table size.
  1910. X *
  1911. X */
  1912. int
  1913. HashCode (sb)
  1914. char sb[];
  1915. X{
  1916. X    int ccSum = 0;            /* sum of char values in string sb */
  1917. X    int i;
  1918. X
  1919. X    for (i = 0; sb[i]; i++)        /* add char codes for sb chars     */
  1920. X        ccSum += sb[i];
  1921. X    return (ccSum % SST);        /* return sum mod table size       */
  1922. X}
  1923. END_OF_FILE
  1924. if test 6799 -ne `wc -c <'src/symtab.c'`; then
  1925.     echo shar: \"'src/symtab.c'\" unpacked with wrong size!
  1926. fi
  1927. # end of 'src/symtab.c'
  1928. fi
  1929. if test -f 'test/test.mc' -a "${1}" != "-c" ; then 
  1930.   echo shar: Will not clobber existing file \"'test/test.mc'\"
  1931. else
  1932. echo shar: Extracting \"'test/test.mc'\" \(4506 characters\)
  1933. sed "s/^X//" >'test/test.mc' <<'END_OF_FILE'
  1934. X/*
  1935. X * Sendmail configuration file for test rulesets
  1936. X *
  1937. X * Simon Kenyon November 20th, 1986
  1938. X */
  1939. X
  1940. bind
  1941. X    EnvelopeTo         = ruleset  0;
  1942. X    From            = ruleset  1;
  1943. X    HeaderTo        = ruleset  2;
  1944. X    Canonicalize        = ruleset  3;
  1945. X    Externalize        = ruleset  4;
  1946. X
  1947. X    LocalHeaderFrom        = ruleset 10;
  1948. X    UucpHeaderFrom        = ruleset 11;
  1949. X
  1950. X    LocalHeaderTo        = ruleset 20;
  1951. X    UucpHeaderTo        = ruleset 21;
  1952. X
  1953. macro
  1954. X    Domain        = "my_domain";
  1955. X    Version        = "ruleset tester V1.0";
  1956. X
  1957. X    m_sitename    = "whatever";
  1958. X    m_oname        = "${m_sitename}.${Domain}";
  1959. X    m_daemon    = "MAILER-DAEMON";
  1960. X    /*m_ufrom        = "From ${m_sreladdr}  ${m_udate} remote from ${m_sitename}";*/
  1961. X    m_ufrom        = "From ${m_sreladdr}  ${m_udate}";
  1962. X    m_addrops    = ".:%@!^=/[]{}";
  1963. X    m_defaddr    = concat (
  1964. X                ifset (m_sname, "${m_sname}    <${m_sreladdr}>",
  1965. X                        "${m_sreladdr}"),
  1966. X                ""
  1967. X              );
  1968. X    m_smtp        = "${m_oname} Sendmail ${m_version}/${Version} ready at ${m_adate}";
  1969. X
  1970. options
  1971. X    o_alias        = "/usr/lib/aliases";
  1972. X    o_delivery    = d_background;
  1973. X    o_dmuid        = "1";
  1974. X    o_flog        = "/usr/lib/sendmail.st";
  1975. X    o_fsmtp        = "/usr/lib/sendmail.hf";
  1976. X    o_gid        = "1";
  1977. X    o_hformat    = "";
  1978. X    o_qdir        = "/usr/spool/mqueue";
  1979. X    o_qtimeout    = "3d";
  1980. X    o_safe        = "";
  1981. X    o_slog        = "9";
  1982. X    o_timezone    = "WET";
  1983. X    o_tmode        = "0644";
  1984. X    o_tread        = "r2h";
  1985. X    o_wizpass    = "*";
  1986. X
  1987. precedence
  1988. X    first-class        =    0;
  1989. X    special-delivery    =  100;
  1990. X    junk            = -100;
  1991. X
  1992. trusted
  1993. X    {root, daemon, uucp, network};
  1994. X    {simon};
  1995. X
  1996. header
  1997. X    define ("a:", "The origination date in Arpanet format = ${m_odate}");
  1998. X    define ("b:", "The current date in Arpanet format = ${m_adate}");
  1999. X    define ("c:", "The hop count = ${m_hops}");
  2000. X    define ("d:", "The date in UNIX (ctime) format = ${m_udate}");
  2001. X    define ("e:", "The SMTP entry message = ${m_smtp}");
  2002. X    define ("f:", "The sender (from) address = ${m_saddr}");
  2003. X    define ("g:", "The sender address relative to the recipient = ${m_sreladdr}");
  2004. X    define ("h:", "The recipient host = ${m_rhost}");
  2005. X    define ("i:", "The queue id = ${m_qid}");
  2006. X    define ("j:", "The official domain name for this site = ${m_oname}");
  2007. X    define ("l:", "The format of the UNIX from line = ${m_ufrom}");
  2008. X    define ("n:", "The name of the daemon (for error messages) = ${m_daemon}");
  2009. X    define ("o:", "The set of operators in addresses = ${m_addrops}");
  2010. X    define ("p:", "Sendmail's pid = ${m_pid}");
  2011. X    define ("q:", "The default format of sender address = ${m_defaddr}");
  2012. X    define ("r:", "Protocol used = ${m_protocol}");
  2013. X    define ("s:", "Sender's host name = ${m_shostname}");
  2014. X    define ("t:", "A numeric representation of the current time = ${m_ctime}");
  2015. X    define ("u:", "The recipient user = ${m_ruser}");
  2016. X    define ("v:", "The version number of sendmail = ${m_version}");
  2017. X    define ("w:", "The hostname of this site = ${m_sitename}");
  2018. X    define ("x:", "The full name of the sender = ${m_sname}");
  2019. X    define ("y:", "The id of the sender's tty = ${m_stty}");
  2020. X    define ("z:", "The home directory of the recipient = ${m_rhdir}");
  2021. X
  2022. field
  2023. X    path        : match (1*);
  2024. X
  2025. ruleset Canonicalize {
  2026. X    if (path)
  2027. X        next ("{3}" $1);
  2028. X}
  2029. X
  2030. ruleset EnvelopeTo {
  2031. X    if (path @ path)
  2032. X        resolve (mailer (uucp),
  2033. X             host ("{0_uucp}" $2),
  2034. X             user ("{0_uucp}" $1));
  2035. X    if (path ! path)
  2036. X        resolve (mailer (uucp),
  2037. X             host ("{0_uucp}" $1),
  2038. X             user ("{0_uucp}" $2));
  2039. X    if (path)
  2040. X        resolve (mailer (local),
  2041. X             user ("{0_local}" $1));
  2042. X}
  2043. X
  2044. ruleset From {
  2045. X    if (path)
  2046. X        return ("{1}" $1);
  2047. X}
  2048. X
  2049. ruleset HeaderTo {
  2050. X    if (path)
  2051. X        return ("{2}" $1);
  2052. X}
  2053. X
  2054. ruleset Externalize {
  2055. X    if (path)
  2056. X        return ("{4}" $1);
  2057. X}
  2058. X
  2059. ruleset LocalHeaderFrom {
  2060. X    if (path)
  2061. X        return ("{S_local}" $1);
  2062. X}
  2063. X
  2064. ruleset LocalHeaderTo {
  2065. X    if (path)
  2066. X        return ("{R_local}" $1);
  2067. X}
  2068. X
  2069. ruleset UucpHeaderFrom {
  2070. X    if (path)
  2071. X        return ("{S_uucp}" $1);
  2072. X}
  2073. X
  2074. ruleset UucpHeaderTo {
  2075. X    if (path)
  2076. X        return ("{R_uucp}" $1);
  2077. X}
  2078. X
  2079. mailer
  2080. X    local {
  2081. X        Path        = "/usr/src/local/EUnet/ease/test/args",
  2082. X        Flags        = {f_date,
  2083. X                   f_from,
  2084. X                   f_locm,
  2085. X                   f_mesg,
  2086. X                   f_mult,
  2087. X                   f_noufrom,
  2088. X                   f_rfrom,
  2089. X                   f_strip},
  2090. X        Sender        = LocalHeaderFrom,
  2091. X        Recipient     = LocalHeaderTo,
  2092. X        Argv        = "args mail -d ${m_ruser}"
  2093. X    };
  2094. X    prog {
  2095. X        Path        = "/usr/src/local/EUnet/ease/test/args",
  2096. X        Flags        = {f_date,
  2097. X                   f_expensive,
  2098. X                   f_from,
  2099. X                   f_locm,
  2100. X                   f_mesg,
  2101. X                   f_noufrom,
  2102. X                   f_strip},
  2103. X        Sender        = LocalHeaderFrom,
  2104. X        Recipient     = LocalHeaderTo,
  2105. X        Argv        = "args sh -c ${m_ruser}"
  2106. X    };
  2107. X    uucp {
  2108. X        Path        = "/usr/src/local/EUnet/ease/test/args",
  2109. X        Flags        = {f_date,
  2110. X                   f_from,
  2111. X                   f_mesg,
  2112. X                   f_strip,
  2113. X                   f_ufrom,
  2114. X                   f_upperh,
  2115. X                   f_upperu},
  2116. X        Sender        = UucpHeaderFrom,
  2117. X        Recipient     = UucpHeaderTo,
  2118. X        Maxsize        = "65535",
  2119. X        Argv        = "args uumail -h -oc -gA -f${m_sreladdr} ${m_rhost}!${m_ruser}"
  2120. X    };
  2121. END_OF_FILE
  2122. if test 4506 -ne `wc -c <'test/test.mc'`; then
  2123.     echo shar: \"'test/test.mc'\" unpacked with wrong size!
  2124. fi
  2125. # end of 'test/test.mc'
  2126. fi
  2127. echo shar: End of archive 2 \(of 6\).
  2128. cp /dev/null ark2isdone
  2129. MISSING=""
  2130. for I in 1 2 3 4 5 6 ; do
  2131.     if test ! -f ark${I}isdone ; then
  2132.     MISSING="${MISSING} ${I}"
  2133.     fi
  2134. done
  2135. if test "${MISSING}" = "" ; then
  2136.     echo You have unpacked all 6 archives.
  2137.     rm -f ark[1-9]isdone
  2138. else
  2139.     echo You still need to unpack the following archives:
  2140.     echo "        " ${MISSING}
  2141. fi
  2142. ##  End of shell archive.
  2143. exit 0
  2144.